package com.example.controller.paibaogong;

import com.example.common.result.Result;
import com.example.entity.dto.paibaogong.AfterClickButtonByMoctyDto;
import com.example.entity.dto.paibaogong.PaiGongListByMoctyDto;
import com.example.entity.vo.paibaogong.PaiGongItemByMoctyVo;
import com.example.entity.vo.paibaogong.ProcessNoListByMoctyListVo;
import com.example.mapper.MoctyMapper;
import com.example.mapper.paibaogong.PaiGongMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/paigong")
@Api(tags = "派工接口")
public class PaiGongController {

    @Autowired
    private MoctyMapper moctyMapper;
    @Autowired
    private PaiGongMapper paiGongMapper;

    @ApiOperation("派工列表(工单级排产，工序级派工)")
    @PostMapping("paiGongListByMocty")
    public Result<PageInfo<PaiGongItemByMoctyVo>> paiGongListByMocty(@RequestBody PaiGongListByMoctyDto dto) {
        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
        List<PaiGongItemByMoctyVo> list = paiGongMapper.paiGongListByMocty(dto);
        PageInfo<PaiGongItemByMoctyVo> pageInfo = new PageInfo<>(list);
        return Result.success(pageInfo);
    }

    @ApiOperation("派工列表(工单级排产，工序级派工) 点击按钮调用工序工艺")
    @PostMapping("afterClickButtonByMocty")
    public Result<List<ProcessNoListByMoctyListVo>> afterClickButtonByMocty(@RequestBody AfterClickButtonByMoctyDto dto) {
        List<ProcessNoListByMoctyListVo> list = paiGongMapper.processNoListByMoctyList(dto.getUuidList());
        return Result.success(list);
    }

    @ApiOperation("派工列表(工单级排产，工序级派工) 提交派工单")
    @PostMapping("submitPaiGong")
    public Result submitPaiGong() {
        return Result.success();
    }

}
